package com.qq.mobilemanager.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.FrameLayout;
import android.widget.RadioGroup;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qq.mobilesafe.R;
import com.qq.mobilesafe.fragment.FirewallBlackFragment;
import com.qq.mobilesafe.fragment.FirewallPhoneFragment;
import com.qq.mobilesafe.fragment.FirewallSmsFragment;
import com.qq.mobilesafe.view.StatusBarCompat;

public class FirewallActivity extends FragmentActivity {
	@ViewInject(R.id.view_pager)
	private ViewPager mViewPager ;
	
	@ViewInject(R.id.tab_layout)
	private TabLayout mTabLayout ;

	@Override
	protected void onCreate(@Nullable Bundle arg) {
		super.onCreate(arg);
		StatusBarCompat.compat(this);
		setContentView(R.layout.activity_firewall);
		ViewUtils.inject(this);
		
		mViewPager.setAdapter(new FirewallFragmentPagerAdapter(getSupportFragmentManager()));
		mTabLayout.setupWithViewPager(mViewPager);
	}

	class FirewallFragmentPagerAdapter extends FragmentStatePagerAdapter {

		public FirewallFragmentPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		private Fragment fragment;
		private String[] title = {"短信拦截","电话拦截","黑名单管理"};

		@Override
		public int getCount() {
			return title.length;
		}

		@Override
		public Fragment getItem(int position) {
			switch (position) {
			case 0:
				fragment = new FirewallSmsFragment();
				break;
			case 1:
				fragment = new FirewallPhoneFragment();
				break;
			case 2:
				fragment = new FirewallBlackFragment();
				break;
			}
			return fragment;
		}
		@Override
		public CharSequence getPageTitle(int position) {
			return title[position];
		}
	}
}
